#!/bin/bash

function preinstall_controller() {
    debconf-set-selections <<< 'maria-db-server mysql-server/root_password password root'
    debconf-set-selections <<< 'maria-db-server mysql-server/root_password_again password root'
    apt-get install -y ceph ceph-mds librbd1 rbd-fuse radosgw \
    apache2 libapache2-mod-wsgi libapache2-mod-fastcgi memcached \
    mariadb-server ntp openssh-server openssl keystone rabbitmq-server \
    expect smartmontools
}

function preinstall_agent() {
    DEBIAN_FRONTEND=noninteractive apt-get install -y ceph ceph-mds librbd1 rbd-fuse radosgw \
    ntp openssh-server python-keystoneclient expect smartmontools
}

if [[ $1 ]]; then
    if [[ $1 == "agent" ]]; then
        preinstall_agent
    else
        preinstall_controller
    fi
else
    preinstall_controller
fi
